﻿using System;

namespace UFrame
{
    public class IntToFloatConverter
    {
        public float[] indexAry;

        public IntToFloatConverter()
        {
            
        }

        public IntToFloatConverter(float [] indexAry)
        {
            this.indexAry = indexAry;
        }
        
        public object Convert(object value)
        {
            int b = (int)value;
            if (b < 0 || b > indexAry.Length)
                return 0;
            return indexAry[b];
        }

        public object ConvertBack(object value)
        {
            int b = (int)value;
            for (int i = 0; i < indexAry.Length; i++)
            {
                if (indexAry[i] == b)
                {
                    return i;
                }
            }
            return 0;
        }
    }
}